package helloworld.admin.action.center;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import helloworld.admin.assembler.center.CenterFormAssembler;
import helloworld.admin.bean.CenterAdminBean;
import helloworld.admin.form.center.CenterForm;
import helloworld.delegate.center.CenterDelegate;

import org.apache.struts.actions.DispatchAction;

public class CenterShowAction extends DispatchAction {
	/*public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		ActionForward nextPage = null;
		if ("Create".equals(request.getParameter("action"))) {
			nextPage = mapping.findForward("centerFormPage");
		} else if ("Edit".equals(request.getParameter("action"))) {
			CustomerDelegate delegate = new CustomerDelegate();
			CustomerDetailObject center = delegate.getCustomerDetail(request
					.getParameter("email"));
			CustomerForm centerForm = CustomerFormAssembler
					.createCustomerForm(center);
			request.setAttribute("CustomerForm", centerForm);
			nextPage = mapping.findForward("centerFormPage");
		}
		return nextPage;
	}*/
	
	public ActionForward Create(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
	throws Exception{
		return mapping.findForward("centerFormPage");
	}
	
	public ActionForward Edit(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
	throws Exception{
		CenterDelegate delegate = new CenterDelegate();
		CenterAdminBean center = delegate.getCenterDetail(request.getParameter("centerName"));
		CenterForm centerForm = CenterFormAssembler.createCenterForm(center);
		request.setAttribute("CenterForm", centerForm);
		return mapping.findForward("centerFormPage");
	}
}
